<template>
  <div>
    <el-select
      multiple
      filterable
      remote
      reserve-keyword
      :remote-method="remoteMethod"
      :loading="executorLoading"
      style="display: block"
      placeholder="请选择"
      v-bind="$attrs"
      v-on="$listeners"
      :value="value"
    >
      <el-option
        v-for="item in executorList"
        :key="item.userId"
        :label="item.name"
        :value="item.userId"
      ></el-option>
    </el-select>
  </div>
</template>
<script>
import { BusinessOpportunities } from '@/api/commercial.js';
export default {
  props: {
    value: {
      default: ''
    },
    oppoId: {
      type: String,
      default: ''
    }
  },
  data () {
    return {
      executorLoading: false,
      executorList: []
    }
  },
  created () {
    this.remoteMethod();
  },
  methods: {
    handleChangeSelect (e) {
      console.log(e)
    },
    // 任务执行人搜索
    remoteMethod (query) {
      this.executorLoading = true;
      BusinessOpportunities.listTeam(this, this.oppoId).then((res) => {
        this.executorList = res.data;
        this.executorLoading = false;
      }).catch((e) => {
        this.executorLoading = false;
      });
    }
  }
};
</script>
<style lang="scss" scoped>
</style>
